//
//  MoBanUnit.m
//  MoBan
//
//  Created by apple on 16/7/7.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "MoBanUnit.h"
#define OneCellH 30*Kscr
#define TwoCellH 120*Kscr
#define ThreeCellH 60*Kscr
#define FourCellH 80*Kscr
@implementation MoBanUnit
+(NSInteger)ZBRowAtIndexpathSection:(NSInteger)section WithArray:(NSMutableArray *)array
{
    if (section<3) {
        return 1;
    }
    
    if (array.count>=4) {
        NSMutableArray *muarray = array[section];
        return muarray.count;
    }
    return 0;
}
+(CGFloat)ZBTableViewHeadHightInSection:(NSInteger)section
{
    
    if (section==0||section==1) {
        return 20*Kscr;//每一个头的高度
    }else if (section==3)
    {
        return 40*Kscr;//下面选择的高度
    }
    return 0.001;
}
+(CGFloat)ZBTableViewFotterHightInSection:(NSInteger)section
{
    if (section==2) {
        return 20*Kscr;//尾的高度
    }
    return 0.01;

}
+(CGFloat)ZBtableviewCellHightInSection:(NSInteger)section WithArray:(NSMutableArray *)array
{
    if (array.count<4) {
        return 0;
    }
    //第一个cellde高度的计算
    
    if (section==0) {
        NSMutableArray *Foodarray = array[0];
        
        if (Foodarray.count<8) {
            if (Foodarray.count%3==0) {
                return (Foodarray.count/3)*OneCellH;
            }else
            {
                return ((Foodarray.count/3)+1)*OneCellH+0.5*(Foodarray.count/3);
            }
        }
        
        return 40*Kscr*3;

    }else if (section==1)
    {
        //第二个cell的高度
        NSMutableArray *array2 =array[1];
        if (array2.count>0) {
            return TwoCellH;//
        }else
        {
            return 0;
        }

    }else if (section==2)
    {
        NSMutableArray *array3 = array[2];
        
        if (array3.count%2==0) {
            return (array3.count/2)*ThreeCellH;
        }else
        {
            return ((array3.count/2)+1)*ThreeCellH;

        }

    }else if (section==3)
    {
        NSMutableArray *array4=array[3];
        if (array4.count>0) {
            return FourCellH;
        }else
        {
            return 0;
        }
    }
    
    return 0;
    
}

+(NSString *)ZBTableviewReuserIndentAtIndexSection:(NSInteger)section
{
    switch (section) {
        case 0:
            return reuseIdentifierOne;
            break;
        case 1:
            return reuseIdentifierTWO;
            break;
        case 2:
            return reuseIdentifierThree;
            break;
            
        default:
            break;
    }
    return nil;
}
///////////////////////collectionview//////////////////////////////////
+(NSString *)ZBCollectionView:(NSString *)reuserIndent
{
    if ([reuserIndent isEqualToString:reuseIdentifierOne]) {
        return @"ZBFirstCollectionViewCell" ;
    }else if ([reuserIndent isEqualToString:reuseIdentifierTWO])
    {
    return @"ZBTwoCollectionViewCell";
    }else if ([reuserIndent isEqualToString:reuseIdentifierThree])
    {
    return @"ZBThreeCollectionViewCell";
    }else if ([reuserIndent isEqualToString:reuseIdentifierFour])
    {
    return @"ZBFourCollectionViewCell";
    }
    return nil;

}
+(CGSize)ZBcollectionViewIteamSizeWith:(NSString *)reuserIndent
{
    if ([reuserIndent isEqualToString:reuseIdentifierOne]) {
        return CGSizeMake(KscrW/3-0.5, OneCellH) ;
    }else if ([reuserIndent isEqualToString:reuseIdentifierTWO])
    {
        return CGSizeMake(KscrW/3-0.5, TwoCellH);
    }else if ([reuserIndent isEqualToString:reuseIdentifierThree])
    {
        return CGSizeMake(KscrW/2-0.5, ThreeCellH-0.5);
    }else if ([reuserIndent isEqualToString:reuseIdentifierFour])
    {
        return CGSizeMake(KscrW/3-0.5, OneCellH);
    }
    return CGSizeMake(0, 0);

    
}
+(void)ZBCollectionViewCell:(UICollectionViewCell *)cell WithResudentfile:(NSString *)resudentfie WithArray:(NSMutableArray *)array InindexRow:(NSInteger)row
{
    if ([resudentfie isEqualToString:reuseIdentifierOne]) {
        [(ZBFirstCollectionViewCell *)cell ZBSetdasouce:array[row]];
    }else if ([resudentfie isEqualToString:reuseIdentifierTWO])
    {
        [(ZBTwoCollectionViewCell *)cell ZBSetTwodasouce:array[row]];
    }else if ([resudentfie isEqualToString:reuseIdentifierThree])
    {
        [(ZBThreeCollectionViewCell *)cell ZBSetThreedasouce:array[row]];
    }

}


@end
